home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 37 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: inforamp.net!usenet
  2. From: pcurran@inforamp.net (Peter Curran)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Alignment of malloc()
  5. Date: Fri, 05 Jan 1996 22:23:15 GMT
  6. Organization: PSC Enterprises
  7. Message-ID: <4ck7k2$2eb@sam.inforamp.net>
  8. References: <DKDA7D.Kw7@midway.uchicago.edu> <j66Sx*FRe@yaps.rhein.de> <DKKHCH.L6r@midway.uchicago.edu> <4ccbdb$5v6@fg70.rz.uni-karlsruhe.de> <DKo8ns.8A9@midway.uchicago.edu>
  9. Reply-To: pcurran@inforamp.net
  10. NNTP-Posting-Host: ts5-07.tor.inforamp.net
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. On Thu, 4 Jan 1996 19:26:16 GMT in article <DKo8ns.8A9@midway.uchicago.edu>
  14.     Michael Spertus<mps@geodesic.com> (Michael Spertus<mps@geodesic.com>) wrote:
  15.  
  16. > ... The problem is that Win32 GlobalAlloc(), which is
  17. >what most allocators use to get their arenas, returns a 32-bit aligned
  18. >pointer. ...  They may also be unaware
  19. >that Pentium PCs use 64 bits data buses). This problem is magnified
  20. >because the Pentium (apparently) drops into microcode on nonaligned
  21. >loads, so that nonaligned floating point benchmarks are over 300%
  22. >slower.
  23.  
  24. >Therefore, any code using floats must align all floating point malloc()
  25. >to avoid running with abysmal efficiency on many of the most popular
  26. >C/C++ compilers. I would like to believe that there should be an
  27. >expectation that "malloc(float)" is a suitable or proper way to
  28. >portably allocate a float ("suitable" and "proper" are the words used
  29. >in the standard and reference documents to describe how malloc() should
  30. >be aligned).
  31. ...
  32.  
  33. The problem here is, of course, that your idea of what is "suitable" and
  34. "proper" is different from other people's.  A large program I am developing does
  35. many malloc()'s, almost all of which are for character-oriented or
  36. short-oriented data.  I do not want to pay the overhead for 64-bit alignment
  37. that would just waste space.  (My program needs all the memory it can get its
  38. hands on.)  So what's the vendor to do?  Compiler options can fix some things,
  39. but it gets trickier at run time.  There are solutions, but the right answer is
  40. a lot more complex than you are suggesting, I think.
  41.  
  42. --
  43. Peter Curran                               pcurran@inforamp.net
  44.  
  45.